
clear; clc; close all;

% 参数设置（Fig.3(a)）
q = 0.7;
a = 2; b = 2; P = 2; Q = 1;
x0 = 2;
y0 = -2;
N = 5000;

% 调用分数阶迭代函数
[x, y] = fracSCLMM(q, a, b, P, Q, x0, y0, N);

% 绘图
figure;
plot(x, y, 'b.', 'MarkerSize', 5);
xlabel('x(n)');
ylabel('y(n)');
title(sprintf('Fig.3(a) 2D-SCLMM 分数阶吸引子，q=%.2f', q));
grid on;

function [x, y] = fracSCLMM(q, a, b, P, Q, x0, y0, N)
    x = zeros(1, N);
    y = zeros(1, N);
    x(1) = x0;
    y(1) = y0;

    % 计算权重（基于Gamma函数定义）
    w = zeros(1, N);
    for k = 1:N
        w(k) = exp(gammaln(k + q - 1) - gammaln(k));
    end
    % 增量序列初始化
    delta_x = zeros(1, N);
    delta_y = zeros(1, N);

    for n = 2:N
        delta_x(n-1) = a * sin(P * y(n-1)) * sin(P * x(n-1)) - x(n-1);
        delta_y(n-1) = b * cos(Q * x(n-1)) * cos(Q * y(n-1)) - y(n-1);

        sum_x = 0;
        sum_y = 0;
        for i = 1:n-1
            sum_x = sum_x + w(n - i) * delta_x(i);
            sum_y = sum_y + w(n - i) * delta_y(i);
        end

        x(n) = x0 + sum_x / gamma(q);
        y(n) = y0 + sum_y / gamma(q);

    end
end
